//
//  SSNormalTableViewCell.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/5/30.
//

import UIKit

class SSNormalTableViewCell: UITableViewCell {

    @IBOutlet weak var imageV: UIImageView!
    
    @IBOutlet weak var tagLab: UILabel!
    
    @IBOutlet weak var titleLab: UILabel!
    
    @IBOutlet weak var priceLab: UILabel!
    
    @IBOutlet weak var tagLab2: UILabel!
    
    @IBOutlet weak var white_card: UIView!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    func setCorner() {
        white_card.layer.cornerRadius = 12
        white_card.layer.maskedCorners = [.layerMinXMaxYCorner,.layerMaxXMaxYCorner]
    }
    
    func cancelCorner() {
        white_card.layer.cornerRadius = 0
        white_card.layer.maskedCorners = [.layerMinXMaxYCorner,.layerMaxXMaxYCorner]
    }
    
    var normal: SSNormal = SSNormal() {
        didSet {
            
            tagLab.text = normal.pkgType
            imageV.setImage(with: normal.pkgImg)
            guard let price = normal.listSpecs.first?.specsPrice else{
                return
            }
            priceLab.text = "$\(price)"
//            normalPrice(label: priceLab, price: price)
            tagLab2.text = splitStr(datas: normal.listTag)
            
            //标题处理
            let str2:NSString = normal.pkgName as NSString
            let range =  str2.range(of: normal.keyword)
            
            let str = stringInsert(string: normal.pkgName, keyword: normal.keyword, insertStr: " ")
            normalStrToTitle2(textLab: titleLab, string: str, range: range)

        }
    }
    
    @IBAction func detailAction(_ sender: Any) {
        let vc = SSNormalDetailController()
        vc.normal = normal
        UIViewController.current().navigationController?.pushViewController(vc, animated: true)
    }
}
